package com.situ.mall.order.interceptor;

import com.situ.mall.base.entity.Member;
import com.situ.mall.base.util.OrderSessionUtil;
import com.situ.mall.base.util.URLUtil;
import lombok.val;
import org.jetbrains.annotations.NotNull;
import org.springframework.core.annotation.Order;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * ClassName: LoginInterceptor
 * Package: com.situ.mall.order.interceptor
 * Description:
 *
 * @Author Darling_达
 * @Create 2023-04-04 16:51
 * @Version 1.0
 */


public class LoginInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Object handler) throws Exception {
        Member m = OrderSessionUtil.getCurrent();
        if (m == null) {
            response.sendRedirect(URLUtil.LOGIN);
            return false;
        }
        return true;
    }

}
